package dq.study.concurrent.queue;

import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * 安全队列 -- 非阻塞队列实现
 * @author dongqun
 * @date 2020/2/8 21:15
 */
public class ConcurrentLinkedQueueTest {
    private static ConcurrentLinkedQueue<Long> queue = new ConcurrentLinkedQueue<Long>();

    public static void main(String[] args) {
        queue.offer(1L);
        queue.offer(2L);
        queue.offer(3L);
        for (int i = 0; i < 100; i++) {
           new Thread(new Runnable() {
               @Override
               public void run() {
                   System.out.println(queue.poll());
               }
           }).start();
        }
    }


}
